package io.gatling.extensions.common.check.string

import io.gatling.commons.validation._
import io.gatling.core.check._
import io.gatling.extensions.common.check.CommonCheckSupport
import io.gatling.extensions.mongodb.check.MongoCheckType

trait StringCheckType

trait StringCheckSupport extends CommonCheckSupport {

  // materializer 的作用是将 R 转为 P，不过我一般直接 R = P
  // 创建隐式 materializer，给 CommonCheckSupport 中的隐式方法使用

  // CheckMaterializer[T, C <: Check[R], R, P]
  implicit val UpdateResultMaterializer: CheckMaterializer[MongoCheckType, Check[String], String, String] = new CheckMaterializer[MongoCheckType, Check[String], String, String](identity) {
    // 这里实际应该用上 type Preparer[R, P] = R => Validation[P] 但是我懒得用了，这样写直接使 P = R
    override protected def preparer: Preparer[String, String] = _.success
  }

  val stringLength: FindCheckBuilder[StringCheckType, String, Int] = StringLengthCheckBuilder

  val string: FindCheckBuilder[StringCheckType, String, String] = StringCheckBuilder
}
